package com.hackathon.chgk.data.dao;

import java.io.Serializable;

import com.j256.ormlite.field.DatabaseField;
import com.j256.ormlite.table.DatabaseTable;

@DatabaseTable
public class Task implements Serializable {

	private static final long serialVersionUID = 1700834703875285679L;

	public static final String HASHCODE_FIELD_NAME = "hash_code";
	public static final String ID_FIELD_NAME = "id";
	public static final String SOURCE_FIELD_NAME = "source";
	public static final String TEXT_FIELD_NAME = "text";
	public static final String ANSWER_FIELD_NAME = "answer";
	public static final String ADDED_DATE_FIELD_NAME = "added_date";
	public static final String AUTHOR_FIELD_NAME = "author";
	public static final String ANSWER_SOURCE_FIELD_NAME = "answer_source";
	public static final String COMMENT_FIELD_NAME = "comment";
	public static final String SHOWCOUNT_FIELD_NAME = "show_count";
	
	@DatabaseField(generatedId = true)
	private Integer id;

	@DatabaseField(columnName = HASHCODE_FIELD_NAME)
	private int hashCode;

	@DatabaseField(columnName = SOURCE_FIELD_NAME, index = true)
	private String source;

	@DatabaseField(columnName = TEXT_FIELD_NAME)
	private String text;
	
	@DatabaseField(columnName = ANSWER_FIELD_NAME)
	private String answer;
	
	@DatabaseField(columnName = ADDED_DATE_FIELD_NAME)
	private long addedDate;
	
	@DatabaseField(columnName = AUTHOR_FIELD_NAME)
	private String author;
	
	@DatabaseField(columnName = ANSWER_SOURCE_FIELD_NAME)
	private String answerSource;
	
	@DatabaseField(columnName = COMMENT_FIELD_NAME)
	private String comment;
	
	@DatabaseField(columnName = SHOWCOUNT_FIELD_NAME)
	private int showCount;

	public String getAnswer() {
		return answer;
	}

	public void setAnswer(String answer) {
		this.answer = answer;
	}

	public String getText() {
		return text;
	}

	public void setText(String text) {
		this.text = text;
		this.hashCode = text.hashCode();
	}

	public String getSource() {
		return source;
	}

	public void setSource(String source) {
		this.source = source;
	}

	public int getHashCode() {
		return hashCode;
	}

	public void setHashCode(int hash_code) {
		this.hashCode = hash_code;
	}

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}
	
	@Override
	public String toString() {
		return text;
	}

	public long getAddedDate() {
		return addedDate;
	}

	public void setAddedDate(long addedDate) {
		this.addedDate = addedDate;
	}

	public String getAuthor() {
		return author;
	}

	public void setAuthor(String author) {
		this.author = author;
	}

	public String getAnswerSource() {
		return answerSource;
	}

	public void setAnswerSource(String answerSource) {
		this.answerSource = answerSource;
	}

	public String getComment() {
		return comment;
	}

	public void setComment(String comment) {
		this.comment = comment;
	}

	public int getShowCount() {
		return showCount;
	}

	public void setShowCount(int showCount) {
		this.showCount = showCount;
	}
	
	public void incrementShowCount() {
		this.showCount++;
	}
}
